﻿<navigation:PageView x:Class="Corina.Cydee.Apphub.Views.Bases.GuobiaoConfigView"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:be="clr-namespace:Corina.Interactivity.Silverlight;assembly=Corina.Interactivity.Silverlight"
                     xmlns:controls="clr-namespace:Corina.Controls.Silverlight;assembly=Corina.Controls.Silverlight"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                     xmlns:localViewmodel="clr-namespace:Corina.Cydee.Apphub.Viewmodels"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:navigation="clr-namespace:Corina.Cydee.Apphub.Base"
                     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                     xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                     d:DesignHeight="480"
                     d:DesignWidth="900"
                     mc:Ignorable="d">

    <navigation:PageView.DataContext>
        <localViewmodel:GuobiaoConfigViewmodel />
    </navigation:PageView.DataContext>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <ei:CallMethodAction MethodName="UILoaded" TargetObject="{Binding}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <toolkit:BusyIndicator BusyContent="{StaticResource IDS_BUSYCONTENT_LOADING}" IsBusy="{Binding IsBusy}">
        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid Grid.Row="1" Margin="0,12,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="12" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <sdk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding ItemsCollection}">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Binding="{Binding ItemIndex}" Header="序号" />
                            <sdk:DataGridTextColumn Binding="{Binding SpecimenKind}" Header="样品种类" />
                            <sdk:DataGridTextColumn Binding="{Binding Name}" Header="检测项目" />
                            <sdk:DataGridTextColumn Binding="{Binding GBName}" Header="国标" />
                            <sdk:DataGridTextColumn Binding="{Binding Code}" Header="国标代码" />
                            <sdk:DataGridTextColumn Binding="{Binding Filename}" Header="文档" />
                            <sdk:DataGridCheckBoxColumn Binding="{Binding HasPreviewImage}" Header="预览图" />
                            <sdk:DataGridTemplateColumn Header="操作">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                                            <HyperlinkButton Margin="0,0,12,0"
                                                             Command="{Binding Path=DataContext.UpdateCommand,
                                                                               RelativeSource={RelativeSource AncestorType=navigation:PageView}}"
                                                             CommandParameter="{Binding }"
                                                             Content="编辑" />
                                            <HyperlinkButton Margin="0,0,12,0" Content="删除" />
                                        </StackPanel>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </Grid>
                <ItemsControl Grid.Column="2" ItemsSource="{Binding GuobiaoCollection}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Margin="0,0,0,12">
                                <Run Text="{Binding Code}" />
                                <Run Text="【" />
                                <Run Text="{Binding Name}" />
                                <Run Text="】" />
                            </TextBlock>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition MinWidth="150" MaxWidth="300" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition MinWidth="150" MaxWidth="300" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBlock VerticalAlignment="Center" Text="检测项目：" />
                <controls:TextBoxExt Grid.Column="1"
                                     PlaceText="如：镉，二价铜"
                                     Text="{Binding SearchMeasureName,
                                                    Mode=TwoWay,
                                                    UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Triggers>
                        <be:TextBoxEnterKeyTrigger>
                            <be:ExecuteCommandAction Command="{Binding LoadCommand}" />
                        </be:TextBoxEnterKeyTrigger>
                    </i:Interaction.Triggers>
                </controls:TextBoxExt>
                <TextBlock Grid.Column="2"
                           VerticalAlignment="Center"
                           Text="国标号：" />
                <controls:TextBoxExt Grid.Column="3"
                                     PlaceText="如：GB2760-2012"
                                     Text="{Binding SearchCode,
                                                    Mode=TwoWay,
                                                    UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Triggers>
                        <be:TextBoxEnterKeyTrigger>
                            <be:ExecuteCommandAction Command="{Binding LoadCommand}" />
                        </be:TextBoxEnterKeyTrigger>
                    </i:Interaction.Triggers>
                </controls:TextBoxExt>
                <StackPanel Grid.Column="5" Orientation="Horizontal">
                    <Button MinWidth="60"
                            Command="{Binding InsertCommand}"
                            Content="新增" />
                </StackPanel>
            </Grid>
            <controls:PromptDialog Title="更新"
                                   Grid.RowSpan="2"
                                   CloseCommand="{Binding CancelCommand}"
                                   Visibility="{Binding ShowUpdate,
                                                        Converter={StaticResource BooleanToVisibilityConverter}}"
                                   WindowHeight="360"
                                   WindowWidth="640">
                <ScrollViewer Margin="12,0" BorderThickness="0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="240" />
                            </Grid.ColumnDefinitions>
                            <StackPanel Margin="0,0,12,0">
                                <Grid Margin="0,6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="样品种类：" />
                                    <sdk:AutoCompleteBox Grid.Column="1"
                                                         Grid.ColumnSpan="2"
                                                         ItemsSource="{Binding SpecimenKindCollection}"
                                                         MinimumPrefixLength="0"
                                                         SelectedItem="{Binding SelectedSpecimenKind,
                                                                                Mode=TwoWay}"
                                                         TabIndex="0"
                                                         ValueMemberPath="Title"
                                                         be:AutoCompleteBoxHelper.OtherPaths="Title">
                                        <sdk:AutoCompleteBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Title}" />
                                            </DataTemplate>
                                        </sdk:AutoCompleteBox.ItemTemplate>
                                    </sdk:AutoCompleteBox>
                                </Grid>
                                <Grid Margin="0,6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="检测项目：" />
                                    <TextBox Grid.Column="1"
                                             Grid.ColumnSpan="2"
                                             IsReadOnly="{Binding MeasureNameReadOnly}"
                                             Text="{Binding MeasureName,
                                                            Mode=TwoWay,
                                                            UpdateSourceTrigger=PropertyChanged}" />
                                </Grid>
                                <Grid Margin="0,6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="国标号：" />
                                    <TextBox Grid.Column="1" Text="{Binding GuobiaoCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                        <i:Interaction.Triggers>
                                            <be:TextBoxEnterKeyTrigger>
                                                <be:ExecuteCommandAction Command="{Binding GetGuobiaoCommand}" />
                                            </be:TextBoxEnterKeyTrigger>
                                        </i:Interaction.Triggers>
                                    </TextBox>
                                    <controls:PathButton Grid.Column="2"
                                                         Margin="12,0,0,0"
                                                         HorizontalAlignment="Left"
                                                         Command="{Binding GetGuobiaoCommand}"
                                                         PathData="{StaticResource ICON_SEARCH}" />
                                </Grid>
                                <Rectangle Margin="0,6" Style="{StaticResource DividerStyle}" />
                                <Grid Margin="0,6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="国标号：" />
                                    <TextBlock Grid.Column="2" Text="{Binding GuobiaoEntity.Code}" />
                                </Grid>
                                <Grid Margin="0,6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="国标名称：" />
                                    <TextBlock Grid.Column="2" Text="{Binding GuobiaoEntity.Name}" />
                                </Grid>
                                <Grid Margin="0,6">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="文件名：" />
                                    <TextBlock Grid.Column="2" Text="{Binding GuobiaoEntity.DocumentName}" />
                                </Grid>
                            </StackPanel>

                            <Image Name="previewImage"
                                   Grid.Column="1"
                                   Width="240"
                                   Source="/Corina.Cydee.Apphub;component/Images/Picture.png"
                                   Stretch="UniformToFill" />
                            <Button Grid.Column="1" Command="{Binding OpenFileCommand}">
                                <Button.Style>
                                    <Style TargetType="Button">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid Background="White" Opacity="0" />
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </Grid>



                        <Grid Grid.Row="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <StackPanel Visibility="{Binding GettingGuobiao, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <TextBlock Text="获取国标信息，请稍后..." />
                                <ProgressBar IsIndeterminate="True" />
                            </StackPanel>

                            <StackPanel Grid.Column="1" Orientation="Horizontal">
                                <Button MinWidth="60"
                                        Margin="12,0"
                                        Command="{Binding SubmitCommand}"
                                        Content="提交" />
                                <Button MinWidth="60"
                                        Command="{Binding CancelCommand}"
                                        Content="取消" />
                            </StackPanel>
                        </Grid>


                    </Grid>
                </ScrollViewer>
            </controls:PromptDialog>
        </Grid>
    </toolkit:BusyIndicator>
</navigation:PageView>
